OpenStack Icehouse : Add Images
2014/08/31 |
Add Virtual Machine images in Glance.
|
|
[1] | Load environment variables first. |
[root@dlp ~]# unset SERVICE_TOKEN [root@dlp ~]# unset SERVICE_ENDPOINT
[root@dlp ~]#
vi ~/keystonerc
export OS_USERNAME=admin
export OS_PASSWORD=adminpassword export OS_TENANT_NAME=admin export OS_AUTH_URL=http://10.0.0.30:35357/v2.0/ export PS1='[\u@\h \W(keystone)]\$ '
[root@dlp ~]#
chmod 600 ~/keystonerc [root@dlp ~]# source ~/keystonerc [root@dlp ~(keystone)]# echo "source ~/keystonerc " >> ~/.bash_profile
# confirm status (it's OK if no errors are shown) [root@dlp ~(keystone)]# glance image-list
+----+------+-------------+------------------+------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +----+------+-------------+------------------+------+--------+ +----+------+-------------+------------------+------+--------+ |
[2] | For example, Create a Virtual Machine image of CentOS 7 for adding. |
# create a disk image [root@dlp ~]# qemu-img create -f qcow2 /var/kvm/images/centos7.img 10G
# install [root@dlp ~]# virt-install \
Starting install...
--name centos7 \ --ram 2048 \ --disk path=/var/kvm/images/centos7.img,format=qcow2 \ --vcpus 2 \ --os-type linux \ --os-variant rhel7 \ --graphics none \ --console pty,target_type=serial \ --location 'http://ftp.iij.ad.jp/pub/linux/centos/7/os/x86_64/' \ --extra-args 'console=ttyS0,115200n8 serial' # installation starts |
[3] |
After installation, change settings in virtual machine like follows and shutdown it.
* delete or comment out the line "HWADDR" and "UUID" in /etc/sysconfig/network-scripts/ifcfg-eth0 * set "dhcp" for "BOOTPROTO" in /etc/sysconfig/network-scripts/ifcfg-eth0 |
[4] | Add the virtual image to Glance. |
[root@dlp ~(keystone)]# glance image-create --name="CentOS7" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/centos7.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 65ac63b8f92a33c1a64005a711e780b5 | | container_format | bare | | created_at | 2014-09-01T12:31:16 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 00a1a855-84a6-4351-962d-81b79c1d6c4c | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | CentOS7 | | owner | 2b658c66b2c647b7ad03083636d31464 | | protected | False | | size | 983629824 | | status | active | | updated_at | 2014-09-01T12:31:23 | | virtual_size | None | +------------------+--------------------------------------+[root@dlp ~(keystone)]# glance image-list +-----------+---------+-------------+------------------+-----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +-----------+---------+-------------+------------------+-----------+--------+ | 00a1a855- | CentOS7 | qcow2 | bare | 983629824 | active | +-----------+---------+-------------+------------------+-----------+--------+ |
[5] | By the way, if you got an image fron internet, it's OK to simplt add it like follows. |
root@dlp:~#
root@dlp:~# wget http://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
glance image-create --name="Ubuntu1404" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | b65cbc63bfa4abb6144dddf43caa6b5e | | container_format | bare | | created_at | 2014-05-05T05:26:46 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 90b2b3fd-d671-4f2f-aba1-b8a890857bd8 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu1404 | | owner | fa66398ac25943629877cc6e459d38ae | | protected | False | | size | 252707328 | | status | active | | updated_at | 2014-05-05T05:26:49 | | virtual_size | None | +------------------+--------------------------------------+ |